package speed2010.application.gui;

import java.util.MissingResourceException;
import java.util.ResourceBundle;

import speed2010.application.usuario.Idioma;

public class Messages {
	private final static String BUNDLE_DEFAULT = "speed2010.application.gui.messages"; //$NON-NLS-1$
	private final static String BUNDLE_US = "speed2010.application.gui.messages_en_US"; //$NON-NLS-1$

	private static ResourceBundle BUNDLE_NAME = ResourceBundle.getBundle(BUNDLE_DEFAULT);

	private Messages() {
	}

	public static String getString(String key) {
		try {
			return BUNDLE_NAME.getString(key);
		} catch (MissingResourceException e) {
			return '!' + key + '!';
		}
	}

	public static void updateLang(Idioma idioma) {
		if (idioma.equals(Idioma.PT_BR)) {
			BUNDLE_NAME = ResourceBundle.getBundle(BUNDLE_DEFAULT);
		} else if (idioma.equals(Idioma.EN_US)) {
			BUNDLE_NAME = ResourceBundle.getBundle(BUNDLE_US);
		}
	}
}
